package CSDN;

  class  Animal{//动物类
    public String name;
    protected int age;
    public   Animal()
    {
    }
    public   Animal(String name,int age)
    {
        this.age=age;
        this.name=name;
    }
    public void eat(String food)
    {
        System.out.println("动物吃"+food);
    }
}
class Dog extends  Animal{//子类无法继承父类中private属性
 public Dog()
 {};
    public  Dog(String name,int age)
    {
        super(name,age);
    }

    public void yell()
    {
        System.out.println("汪汪汪");
    }

}
class Main
{
    public static void main(String[] args)
    {
        Dog dog=new Dog();
        dog.eat("狗粮");//继承了父类的功能
        dog.yell();  //自己拓展的方法
    }
}
